/* Check JER_Erasures_To_Erased(). */
#include <stdio.h>
#include "jerasure.h"
#include "reed_sol.h"

int main( int argc, char** argv )
{
	int *old_bitmatrix;
	int *inverse_matrix;
	int i, j;
	int m = atoi( argv[1] );
	int k = atoi( argv[2] );
	int w = atoi( argv[3] );
	int size;
	unsigned char* buffer;
	unsigned char** data_ptrs;
	unsigned char** coding_ptrs;
	int *erasures;
	int *erased;
	int tmp;

	erasures = (int*) malloc( sizeof(int) );
	erasures[0] = -1;

	size = 8 * w;
	
	srand48(m);
	for( i = 0; i < m; i++ )
	{
		tmp = lrand48() % (k+m);
		for( j = 0; erasures[j] != -1 && erasures[j] != tmp; j++ );
		if( erasures[j] == -1 )
		{
			erasures = (int*) realloc( erasures, (j+2) * sizeof(int) );
			erasures[j] = tmp;
			erasures[j+1] = -1;
		}
	}

	erased = jerasure_erasures_to_erased( k, m, erasures );

	for( i = 0; i < k+m; i++ )
		fprintf( stdout, "%u ", erased[i] );
	fprintf( stdout, "\n" );
	return 0;
}
